﻿<?xml  version="1.0"   encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"                       
                xmlns:user="http" 
                version="1.0" 
               >  
<msxsl:script language="JScript"  implements-prefix="user">
<![CDATA[
function getImgSrc(nodelist,vIndex){
   var currentNode=nodelist.nextNode();    
   var vTotal=currentNode.parentNode.childNodes.length;      
   var vHasSub=currentNode.childNodes.length>0?true:false;
   if (!vHasSub){
     var vSrc=vIndex!=vTotal?"join.gif":"joinbottom.gif";   
     var vLink="";
   }  
   else{     
     var vSrc=vIndex!=vTotal?"plus.gif":"plusbottom.gif";
     var vLink="onclick=\"showSubClass()\"";
   }  
   return " <img  "+ vLink+" style='cursor:hand' src='../../images/"+vSrc+"' align='absmiddle'/>";   
}

function hasSub(nodelist){
   var currentNode=nodelist.nextNode();    
   return currentNode.childNodes.length>0?1:0;
}

function getBgSrc(nodelist,vIndex){
   var currentNode=nodelist.nextNode();    
   var vTotal=currentNode.parentNode.childNodes.length;
   var vSrc=vIndex==vTotal?"":"line.gif";   
   return "../../images/"+vSrc;
}

function getTypeImg(nodelist){ 
   var currentNode=nodelist.nextNode();   
   var vLevel=currentNode.getAttribute("form");
   var vSrc="categroy.gif";
   if(vLevel=="ReportForm")
      vSrc="page.gif"; 
   else if (vLevel=="MarkForm")
      vSrc="folder.gif";
   else     
      vSrc="folderstatic.gif";      
   return "<img src='"+currentNode.getAttribute("headImage")+"' align='absmiddle'/>";
}
]]></msxsl:script>

<xsl:param name="IsExpand" select="'0'"/>
<xsl:param name="module" select="''"/>
<xsl:param name="layer" select="'0'"/>

<xsl:template match="MenuTree"> 
 <div style="overflow:auto">
 <Table WIDTH="100%" BORDER="0"  CELLSPACING="0" CELLPADDING="0">
   <xsl:choose>
    <xsl:when test="$module!=''">
     <xsl:apply-templates select="MenuNode[@module=$module]"/>
    </xsl:when>
    <xsl:otherwise>	
      <xsl:apply-templates select="MenuNode"/>
    </xsl:otherwise>
   </xsl:choose>    
 </Table>
 </div>
</xsl:template>

 <xsl:template match="MenuNode"> 
 <xsl:variable name="hasSub"  select="user:hasSub(.)"/>
 <tr valign="middle">
 <td width="19" height="16"><xsl:value-of select="user:getImgSrc(.,position())" disable-output-escaping="yes"/></td>   
 <td noWrap="noWrap" width="100%" ><xsl:value-of select="user:getTypeImg(.)" disable-output-escaping="yes"/>      
       <xsl:choose>
       <xsl:when test="@form='MarkForm'">
         <xsl:value-of select="@name"/>
       </xsl:when>
       <xsl:otherwise>	
       <a class="menu_itemlink" href="#" onmousedown="fn_highLight()">
       <xsl:if test="@isfirstitem='1'">
       <xsl:attribute name="highlight" >true</xsl:attribute>
       </xsl:if>
       <xsl:attribute name="onclick" >fn_openLink('<xsl:value-of select="@url"/>');return false</xsl:attribute>
       <xsl:attribute name="target" ><xsl:value-of select="@target"/></xsl:attribute><xsl:value-of select="@name"/>
       </a>
       </xsl:otherwise>
       </xsl:choose>
 </td>          
 </tr> 
  <xsl:if test="$hasSub=1"> 
 <tr> 
     <td width="19" valign="middle">
       <xsl:attribute name="background" ><xsl:value-of select="user:getBgSrc(.,position())" /></xsl:attribute>       
     </td>   
     <td valign="middle" width="100%">
       <xsl:attribute name="style">
        <xsl:choose>
          <xsl:when test="$IsExpand='1'">
           display:block
          </xsl:when>
          <xsl:otherwise>
            display:none
          </xsl:otherwise>
        </xsl:choose>
       </xsl:attribute>
       <Table WIDTH="100%" BORDER="0"  CELLSPACING="0" CELLPADDING="0">
         <xsl:apply-templates select="MenuNode"/>
       </Table>
     </td>
   </tr>
 </xsl:if>
 </xsl:template>
</xsl:stylesheet>
